<%@ tag body-content="scriptless" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ attribute name="name" required="true" %>

<spring:hasBindErrors name="${name}">
<div id="errorDivWrap" align="center" style="width:600px;">
  <div id="errors" class="errors" align="center">
    <input type="hidden" id="numberOfErrors" name="numberOfErrors" value="${fn:length(errors.allErrors)}"/>
    <table align="center" style="margin-left:5px;">
      <c:forEach items="${errors.allErrors}" var="error">
      <tr>
        <c:set var="codeCount">${fn:length(error.codes)}</c:set>
        <c:set var="errorMessageCode"></c:set>
        <c:forEach items="${error.codes}" var="currentCode">
          <c:if test="${currentCode == 'typeMismatch.org.joda.time.DateTime'}"><c:set var="errorMessageCode">${currentCode}</c:set></c:if>
        </c:forEach>
        <c:if test="${errorMessageCode == ''}"><c:set var="errorMessageCode">${error.codes[codeCount-1]}</c:set></c:if>
        <td class='errorText'><spring:message code="${errorMessageCode}" arguments="${error.arguments}"/></td>
       </tr>
       </c:forEach>
     </table>
   </div>
</div>
</spring:hasBindErrors>